package cn.mrlong.base.utils.websocket

import android.annotation.SuppressLint
import android.content.Context
import android.os.Build
import android.webkit.WebSettings
import androidx.annotation.RequiresApi
import java.text.SimpleDateFormat
import java.util.*

object Tools {
    @SuppressLint("SimpleDateFormat")
    fun format(time: Long, style: String = "yyyy-MM-dd HH:mm:ss SSS"): String {
        val sdf = SimpleDateFormat(style)
        val date = Date(time)
        return sdf.format(date)
    }

    @RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    fun getUserAgent(context: Context): String {
        return WebSettings.getDefaultUserAgent(context)
    }
}